﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using WeatherReader;
using System.Web.UI.DataVisualization.Charting;

public partial class DailyGraph : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        var db = new WeatherDbDataContext();
        var date = DateTime.Today.AddDays(-2);

        
        var dataSet = (from r in  db.Readings 
                       where(r.rd_dateTime >  DateTime.Now.AddDays(-1))
                        select new {Date  = r.rd_dateTime, OutsideTemp =  r.rd_temp, InsideTemp = r.rd_insideTemp , Pressure = r.rd_pressure});
        

        Chart1.DataSource = dataSet;
        Chart1.Series["OutsideTemp"].XValueMember = "Date";
        Chart1.Series["OutsideTemp"].YValueMembers = "OutsideTemp";
        Chart1.Series["OutsideTemp"].ChartType = SeriesChartType.Line;

        Chart1.Series["InsideTemp"].XValueMember = "Date";
        Chart1.Series["InsideTemp"].YValueMembers = "InsideTemp";
        Chart1.Series["InsideTemp"].ChartType = SeriesChartType.Line;
        Chart1.ChartAreas["ChartArea1"].AxisX.Interval = .1;


        //Chart1.Series["Pressure"].XValueMember = "Date";
        //Chart1.Series["Pressure"].YValueMembers = "Pressure";
        //Chart1.Series["Pressure"].ChartType = SeriesChartType.Line;

        Chart1.ChartAreas["ChartArea1"].AxisX.TextOrientation = TextOrientation.Stacked;
        Chart1.ChartAreas["ChartArea1"].AxisX.LabelStyle.Format = "dd MM yy - HH:mm:ss";
        Chart1.DataBind();

    }
}
